//
//  ImportantIndurstryViewController.m
//  Utils
//
//  Created by enghou on 2018/6/19.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "ImportantIndurstryViewController.h"
#import "ImportantIndurstrySearchViewController.h"
#import "LocalPersistent.h"
#import "ImportantIndurstryDetailViewController.h"
#import "ImportantIndurstryItemModel.h"
@implementation ImportantIndurstryViewController

-(instancetype)init{
    self = [super init];
    if (self) {
        self.cellClass = @"ImportantIndurstryCell";
        self.modelClsName = @"ImportantIndurstryItemModel";
        self.path = @"/mobile/comprehensiveGovernance/keyIndustry/getKeyIndustryList.action";
    }
    return self;
}

-(void)viewDidLoad{
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(beginRefresh) name:@"refresh_indurstry" object:nil];
}

-(void)addAction{
    ImportantIndurstryDetailViewController *detail = [[ImportantIndurstryDetailViewController alloc]init];
    detail.title = @"重点行业新增";
    [self push:detail];
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    ImportantIndurstryItemModel *model = self.source[indexPath.row];
    ImportantIndurstryDetailViewController *detail = [[ImportantIndurstryDetailViewController alloc]init];
    detail.title = @"重点行业详情";
    detail.ids = model.ID;
    [self push:detail];
}

-(void)fetchModel:(id)model{
    if ([model isKindOfClass:[NSDictionary class]]) {
        self.choosenParam = model;
    }else if ([model isKindOfClass:[NSString class]]){
        [[LocalPersistent sharedInstance]saveContent:model forKey:@"orgId"];
    }
    [self beginRefresh];
}

-(NSDictionary *)param{
    NSMutableDictionary *param = [NSMutableDictionary dictionary];
    [param setObject:[NSString stringWithFormat:@"%li",self.page] forKey:@"page"];
    [param setObject:@"10" forKey:@"rows"];
    if ([self.choosenParam isKindOfClass:[NSDictionary class]]) {
        [param addEntriesFromDictionary:self.choosenParam];
    }
    return param;
}

-(void)searchAction{
    ImportantIndurstrySearchViewController *search = [[ImportantIndurstrySearchViewController alloc]init];
    search.title = @"重点行业查询";
    search.theDelete = self;
    [self push:search];
}

@end
